package net.mysoft.budgetsoft.system.action;

import java.util.ArrayList;
import java.util.List;

import net.mysoft.budgetsoft.system.pagemodel.Main;
import net.mysoft.framework.authority.AccessType;
import net.mysoft.framework.authority.Permission;
import net.mysoft.framework.base.BaseAction;
import net.mysoft.framework.cache.Cache;
import net.mysoft.framework.cache.CacheManager;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Result;
import org.springframework.stereotype.Controller;

import com.opensymphony.xwork2.ModelDriven;

@Action(value = "mainAction", results = { 
		@Result(name = "index", location = "/platform/index.jsp"),
		@Result(name = "north", location = "/platform/layout/north.jsp"),
		@Result(name = "west", location = "/platform/layout/west.jsp"),
		@Result(name = "east", location = "/platform/layout/east.jsp"),
		@Result(name = "center", location = "/platform/layout/center.jsp"),
		@Result(name = "south", location = "/platform/layout/south.jsp")})
@Controller("mainAction2")
public class MainAction2 extends BaseAction implements ModelDriven<Main>{

	/**
	 * 
	 */
	private static final long serialVersionUID = -6010722062357496555L;
	private Main main = new Main();
	
	@Override
	public Main getModel() {
		return main;
	}
	
	public Main getMain() {
		return main;
	}
	public void setMain(Main main) {
		this.main = main;
	}
	
	@Permission(access=AccessType.LOGIN)
	public String execute(){
		return "index";
	}
	@Permission(access=AccessType.LOGIN)
	public String north(){
		return "north";
	}
	@Permission(access=AccessType.LOGIN)
	public String west(){
		return "west";
	}
	@Permission(access=AccessType.LOGIN)
	public String east(){
		return "east";
	}
	@Permission(access=AccessType.LOGIN)
	public String center(){
		return "center";
	}
	@Permission(access=AccessType.LOGIN)
	public String south(){
		return "south";
	}
	@Permission(access=AccessType.LOGIN)
	public void cache(){
//		System.out.println("gdsjffgggggggggggggg");
		Object o = CacheManager.getContent(main.getCacheKey());
		List list = new ArrayList();
		if(o!=null){
			Cache cache = (Cache)o;
			list = (List)cache.getValue() ;
		}
		super.writeJson(list);
	}
	
}
